﻿@model Mix.Cms.Lib.ViewModels.MixDatabaseDatas.ReadMvcViewModel
@{
    string master = MixService.GetConfig<string>(MixAppSettingKeywords.ThemeName, ViewBag.culture);
    string templateFolder = MixCmsHelper.GetTemplateFolder(ViewBag.culture);
    string layout = Model.Property<string>("master_path") ?? "Masters/_Layout.cshtml";
    var masterTemplate = await MixCmsHelper.GetTemplateByPath(master, layout);
    Layout = $"{templateFolder}/{layout}";
    MixCmsHelper.GetAttributeDataListBySet(Context, "services", ViewBag.culture);
}
<div>
    <preview-popup ng-if="isInit" preview-object="previewObject"></preview-popup>

    <input type="hidden" id="view-type" value="Data" />
    <input type="hidden" id="view-id" value="@Model.Id" />    
    @if (!string.IsNullOrEmpty(Model.TemplatePath))
    {
        try
        {
            <partial name="@Model.TemplatePath" model="@Model" />
        }
        catch (System.InvalidOperationException invalidOperationException)
        {
            <p class="danger text-center has-error">Unable load template with Exception detail below:</p>
            <code>
                @invalidOperationException
            </code>

        }
        catch (Exception ex)
        {
            <code>
                @ex
            </code>
            <p class="danger text-center has-error">Unable load template</p>
        }
    }
    else
    {
        <section class="container">
            <h1>@(MixService.Translate<string>("Please choose template", ViewBag.culture))</h1>
        </section>
    }
</div>
@{    
    string url = ViewData["OgUrl"] != null ? (string)ViewData["OgUrl"] : Model.PreviewUrl;
    string title = ViewData["OgTitle"] != null ? (string)ViewData["OgTitle"] : Model.Property<string>("title");
    ViewData["Title"] = ViewData["Title"] != null ? (string)ViewData["Title"] : Model.Property<string>("title");
    string desc = ViewData["OgDescription"] != null ? (string)ViewData["OgDescription"] : Model.Property<string>("seo_description");
    string image = ViewData["OgImage"] != null ? (string)ViewData["OgImage"] : Model.Property<string>("image");

    var domain = url.IndexOf("http") == -1 ? $"{Context.Request.Scheme}://{Context.Request.Host}": string.Empty;
}
@section Seo{
    @*<title>@(MixService.GetConfig<string>("SiteName", ViewBag.culture)) - @Model.SeoTitle</title>*@
    <meta property="og:type" content="website" />
    <!--points to the regular HTML version of the AMP HTML document or to itself if no such HTML version exists-->
    <link rel="canonical" href="@domain@url">
    <meta property="og:url" content="@domain@url" />
    @*<meta property="og:title" content="@title" />
    <meta property="og:description"
          content="@desc" />
    <meta property="og:image" content="@image" />
    <meta name="title" content="@title" />
    <meta name="description" content="@desc" />
    <meta name="keywords" content="@desc" />*@
}
@section Styles{
    @Html.Raw(masterTemplate?.Styles)
    @*@Html.Raw(Model.View?.Styles)*@
}
@section Scripts{
    @Html.Raw(masterTemplate?.Scripts)
    @*@Html.Raw(Model.View?.Scripts)*@
}